package com.nCoV.EpidemicSurveillance.repository;


import com.nCoV.EpidemicSurveillance.domain.DemoNode;

import java.util.List;

import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;

/**
 * @author 罗穆健
 * @date 2020年3月3日
 */
@Component
public interface demoRepository extends Neo4jRepository<DemoNode, Long>{
	
	@Query("MATCH (n:User) RETURN n ")
    List<DemoNode> getUserNodeList();

    @Query("create (n:User{name:{name}}) RETURN n ")
    List<DemoNode> addUserNodeList(@Param("name") String name);
    
    @Query("LOAD CSV WITH HEADERS FROM 'file:///test.csv' AS line merge (:test3{id:line.id,name:line.name,age:line.age})")
    List<DemoNode> addUser();

    @Query("LOAD CSV WITH HEADERS FROM 'file:///test2.csv' AS line "
    		+ "match (from:test3{id:line.aid}),(to:test3{id:line.qid})"
    		+ "merge (from)-[r:stay_at{starttime:line.time,endtime:line.endtime}]->(to)")
    List<DemoNode> addRelation();
}
